/**
 * Created by hcadmin on 16/4/18.
 */
define([
    "jquery",
    "IO",
    "UPLOADUI",
    "UPLOAD",
    "jqueryUI",
    "bootbox"
], function ($, IO, upui, up, jui, bootbox, definebt) {
    $(function () {
        var realname= $("#realname").val();
        gettable(realname);
        $("#select-btn").bind("click", function () {
            var realname= $("#realname").val();
            gettable(realname);
        });
    });

    function gettable(realname){

        var grid;
        //每列数据列性
        var columns = [
            {
                title: '医生ID',
                dataIndex: ' doctor_id',
                dataSource: function (data, datarow, gridobj, current_column) {

                    return "<span>" + data[datarow]. doctor_id + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '医生姓名',//-----------------------
                dataIndex: 'realname',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].realname + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '类别',
                dataIndex: 'doctor_type_name',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow]['doctorType'].doctor_type_name + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '医院',
                dataIndex: 'hospital_name',//-----------------------------------
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow]['hospital'].hospital_name  + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '科室',
                dataIndex: 'department_name',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow]['department'].department_name + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '职称',
                dataIndex: 'duty_name',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow]['duty'].duty_name+ "</span>";

                }
            },
            {
                title: '职务评分',
                dataIndex: 'service_avgscore',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].service_avgscore + "</span>";
                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: ' 粉丝数',
                dataIndex: 'fans_count',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].fans_count + "</span>";

                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '服务金额(元/单)',
                dataIndex: 'asset',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].asset + "</span>";

                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '服务单数',
                dataIndex: 'service_count',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].service_count + "</span>";

                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '账户金额',//---------------------------------------
                dataIndex: 'asset',
                dataSource: function (data, datarow, gridobj, current_column) {
                    return "<span>" + data[datarow].asset + "</span>";

                    //return "<span><img src='" + data[datarow].user_name + "' width='80px;' height='80px;'>&nbsp;&nbsp;</span>" + data[datarow].title + "</span>";
                }
            },
            {
                title: '操作',
                dataIndex: 'action',
                dataSource: function (data, datarow, gridobj, current_column) {

                    return "<a  href='#' class='editmodal' data-toggle='modal' data-target='#myModal' act_id="+data[datarow].doctor_id+"><span style='color: #6ab7ad;'>" + "置顶热点" + "</span></a>";

                }
            }
        ];
        //数组初始化
        function dataInit(realname) {

            grid = new Grid("/api/doctorlist", $("#table_my_toast"), $("#paging_my_toast"), 1, 10, columns, get_input_param(realname), 10);

            //初始化
            grid.Init();
        }

        //获取输入框内容
        function get_input_param(realname) {

            var param="realname="+realname+"&is_top=0";
            return param;
        }
        dataInit(realname);
    }
    $(document).on("click",".editmodal",function(){
        var act_id=$(this).attr("act_id");
        bootbox.confirm("确定要置顶热榜吗？",function(result){
            if(result) {
                var params={};
                params["act_id"]=act_id;
                params["top"]=1;
                IO.post("/api/hot_list",params,function(d){
                    if(d.code==0){
                        var realname= $("#realname").val();
                        gettable(realname);
                    }
                });
            }
        });
    });

});
/**
 * Created by hcadmin on 16/4/18.
 */
